﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace RNGCryptoServiceProviderSample
{
    class Program
    {
public static string CreateKey(int len)
{
    byte[] bytes = new byte[len];
    RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();
    provider.GetBytes(bytes);

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < bytes.Length; i++)
    {
        sb.Append(string.Format("{0:X2}", bytes[i]));
    }

    return sb.ToString();
}

        static void Main(string[] args)
        {
            string validationKey = CreateKey(20);
            Console.WriteLine(validationKey);

            string decryptionKey = CreateKey(24);
            Console.WriteLine(decryptionKey);
        }
    }
}
